<template>
  <div class="es-block">
    <Title>暴雨分级图</Title>
    <div style="width: 100%; height: 90%" class="img-box">
      <!-- <Chart :option="option" /> -->
      <div>
        <img src="@/assets/images/level/1.png" alt="" />
        <div>
          <span style="color: #3499fc;"> 暴雨蓝色预警 </span>
          <span>1h降雨达30mm;6h降雨达50mm;24h降雨达70mm</span>
        </div>

      </div>
      <div>
        <img src="@/assets/images/level/2.png" alt="" />
        <div>
          <span style="color: #fdd72e;"> 暴雨黄色预警 </span>
          <span>1h降雨达50mm;6h降雨达70mm;24h降雨达100mm</span>
        </div>
      </div>
      <div>
        <img src="@/assets/images/level/3.png" alt="" />
        <div>
          <span style="color: #fba402;"> 暴雨橙色预警 </span>
          <span>1h降雨达70mm;6h降雨达100mm;24h降雨达150mm</span>
        </div>
      </div>
      <div>
        <img src="@/assets/images/level/4.png" alt="" />
        <div>
          <span style="color: #e55159;"> 暴雨红色预警 </span>
          <span>1h降雨达100mm;6h降雨达150mm;24h降雨达200mm</span>
        </div>
      </div>
    </div>
  </div>
</template>

<script setup lang="ts">
import { ref } from 'vue'
import Title from '../Title.vue'
import Chart from '@/components/chart/Chart.vue'
import allData from '@/assets/data/trend.json'
import * as echarts from 'echarts'
const choiceType = 'map'
const option = ref({
  series: [
    {
      type: 'treemap',
      data: [
        {
          name: 'nodeA',
          value: 10,
          children: [
            {
              name: 'nodeAa',
              value: 4,
            },
            {
              name: 'nodeAb',
              value: 6,
            },
          ],
        },
        {
          name: 'nodeB',
          value: 20,
          children: [
            {
              name: 'nodeBa',
              value: 20,
              children: [
                {
                  name: 'nodeBa1',
                  value: 20,
                },
              ],
            },
          ],
        },
      ],
    },
  ],
})

function getSeries() {
  // 半透明的颜色值
  const colorArr1 = [
    'rgba(11, 168, 44, 0.5)',
    'rgba(44, 110, 255, 0.5)',
    'rgba(22, 242, 217, 0.5)',
    'rgba(254, 33, 30, 0.5)',
    'rgba(250, 105, 0, 0.5)',
  ]
  // 全透明的颜色值
  const colorArr2 = [
    'rgba(11, 168, 44, 0)',
    'rgba(44, 110, 255, 0)',
    'rgba(22, 242, 217, 0)',
    'rgba(254, 33, 30, 0)',
    'rgba(250, 105, 0, 0)',
  ]
  // y轴的数据 series下的数据
  const valueArr = allData[choiceType].data
  const seriesArr = valueArr.map((item, index) => {
    return {
      name: item.name,
      type: 'line',
      data: item.data,
      stack: choiceType,
      itemStyle: {
        borderWidth: 4,
      },
      lineStyle: {
        width: 3,
      },
      symbolSize: 0,
      symbol: 'circle',
      smooth: true,
      areaStyle: {
        color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
          {
            offset: 0,
            color: colorArr1[index],
          }, // %0的颜色值
          {
            offset: 1,
            color: colorArr2[index],
          }, // 100%的颜色值
        ]),
      },
    }
  })

  return seriesArr
}
</script>

<style lang="scss" scoped>
.es-block {
  width: 100%;
  height: 100%;
}

.img-box {
  display: flex;
  flex-direction: column;
  margin-top: 10px;
}

.img-box>div {
  display: flex;
  align-items: center;
  padding: 4px;
  font-size: 14px;
}

.img-box img {
  width: 50px;
  height: auto;
  border-radius: 8px;
}

.img-box span {
  margin-left: 10px;
  line-height: 18px;
  display: block;
}
</style>
